import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

class DivStyle with Diagnosticable {

  /// Div样式表
  DivStyle({
    this.align,
    this.padding,
    this.margin,
    this.width,
    this.height,
    this.color,
    this.border,
    this.radius,
    this.image,
    this.boxShadow,
    this.gradient,
    this.clip = Clip.none,
    this.mainAlign,
    this.mainSize,
    this.crossAlign,
  });

  AlignmentGeometry? align;
  EdgeInsets? padding;
  EdgeInsets? margin;
  BorderRadius? radius;
  double? width;
  double? height;
  Color? color;
  BoxBorder? border;
  DecorationImage? image;
  List<BoxShadow>? boxShadow;
  Gradient? gradient;

  Clip clip;

  MainAxisAlignment? mainAlign;
  MainAxisSize? mainSize;
  CrossAxisAlignment? crossAlign;

  DivStyle copyWith({
    AlignmentGeometry? align,
    EdgeInsets? padding,
    EdgeInsets? margin,
    BorderRadius? radius,
    double? width,
    double? height,
    Color? color,
    BoxBorder? border,
    DecorationImage? image,
    List<BoxShadow>? boxShadow,
    Gradient? gradient,
    Clip? clip,
    MainAxisAlignment? mainAlign,
    MainAxisSize? mainSize,
    CrossAxisAlignment? crossAlign,
  }){
    return DivStyle(
      align: align ?? this.align,
      padding: padding ?? this.padding,
      margin: margin ?? this.margin,
      radius: radius ?? this.radius,
      width: width ?? this.width,
      height: height ?? this.height,
      color: color ?? this.color,
      border: border ?? this.border,
      image: image ?? this.image,
      boxShadow: boxShadow ?? this.boxShadow,
      gradient: gradient ?? this.gradient,
      clip: clip ?? this.clip,
      mainAlign: mainAlign ?? this.mainAlign,
      mainSize: mainSize ?? this.mainSize,
      crossAlign: crossAlign ?? this.crossAlign,
    );
  }

  DivStyle merge(DivStyle? other) {
    return copyWith(
      align: other?.align,
      padding: other?.padding,
      margin: other?.margin,
      radius: other?.radius,
      width: other?.width,
      height: other?.height,
      color: other?.color,
      border: other?.border,
      image: other?.image,
      boxShadow: other?.boxShadow,
      gradient: other?.gradient,
      clip: other?.clip,
      mainAlign: other?.mainAlign,
      mainSize: other?.mainSize,
      crossAlign: other?.crossAlign,
    );
  }

  ///外边距-左
  DivStyle ml(double value){
    this.margin = this.margin==null ? EdgeInsets.only(left: value) : this.margin!.copyWith(left: value);
    return this;
  }

  ///外边距-上
  DivStyle mt(double value){
    this.margin = this.margin==null ? EdgeInsets.only(top: value) : this.margin!.copyWith(top: value);
    return this;
  }

  ///外边距-右
  DivStyle mr(double value){
    this.margin = this.margin==null ? EdgeInsets.only(right: value) : this.margin!.copyWith(right: value);
    return this;
  }

  ///外边距-下
  DivStyle mb(double value){
    this.margin = this.margin==null ? EdgeInsets.only(bottom: value) : this.margin!.copyWith(bottom: value);
    return this;
  }

  ///外边距-上下
  DivStyle mtb(double value){
    this.margin = this.margin==null ? EdgeInsets.only(top: value, bottom: value) : this.margin!.copyWith(top: value, bottom: value);
    return this;
  }

  ///外边距-左右
  DivStyle mlr(double value){
    this.margin = this.margin==null ? EdgeInsets.only(left: value, right: value) : this.margin!.copyWith(left: value, right: value);
    return this;
  }

  ///外边距-全部
  DivStyle ma(double value){
    this.margin = EdgeInsets.all(value);
    return this;
  }

  ///内边距-左
  DivStyle pl(double value){
    // this.margin = [value, value, value, value];
    return this;
  }

  ///内边距-上
  DivStyle pt(double value){
    // this.margin = [value, value, value, value];
    return this;
  }

  ///内边距-右
  DivStyle pr(double value){
    // this.margin = [value, value, value, value];
    return this;
  }

  ///内边距-下
  DivStyle pb(double value){
    // this.margin = [value, value, value, value];
    return this;
  }
}
